package com.lianxin.fmank_backstage.service;

import com.lianxin.fmank_backstage.dao.TrafficAnalyDao;
import com.lianxin.fmank_backstage.pojo.FlowOverView;
import com.lianxin.fmank_backstage.pojo.TrafficAnalyRes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TrafficAnalyServiceImpl implements TrafficAnalyService {

    @Autowired
    TrafficAnalyDao trafficAnalyDao;

    @Override
    public TrafficAnalyRes getTrafficAnalyTable(String dt1, String dt2) {
        String sql = "select \n" +
                "*\n" +
                "\n" +
                "from ads_apl_tfc_ov\n" +
                "where \n" +
                "province is null\n" +
                "and city is null\n" +
                "and district is null\n" +
                "and devicetype is null\n" +
                "and osname is null\n" +
                "and osver is null\n" +
                "and appid is null\n" +
                "and appver is null\n" +
                "and release_ch  is null\n" +
                "and promotion_ch is null\n" +
                "and dt between '2019-10-28' and '2019-10-30'";
        List<FlowOverView> items = trafficAnalyDao.getTrafficAnalyRecords(sql);
        int code = 0;
        String msg = "ok";
        int count = items.size();

        TrafficAnalyRes res = TrafficAnalyRes.of(code, msg, count, items);
        return res;
    }
}
